package org.annoflow.filter;

import java.util.HashMap;

import org.annoflow.policy.PolicyType;
import org.annoflow.policy.PolicyManager;
import org.apache.log4j.Logger;

public class NetworkFilter implements FilterPoint 
{
	private static Logger logger = Logger.getLogger(AuditFilter.class);
	
	@Override
	public String getFilterCode() 
	{
		return "org.annoflow.filter.NetworkFilter.runFilter($args);";
	}
	public static void runFilter(Object[] args) 
	{		
		logger.info("Executing NetworkFilter");
		
		//Setup context parameters
		HashMap<String, String> params = new HashMap<String, String>();
		params.put("type", "network");
		
		//Check arguments to method
		PolicyType policy = null;
		for(Object arg : args) {
			policy = null;
			if ((policy = PolicyManager.lookupClassPolicy(arg.getClass())) != null) {
				try  {
					policy.assess(params);
				}
				catch (Exception ex) {
					throw new RuntimeException();
				}
			}
		}
	}
	@Override
	public String getReturnFilterCode() {
		// TODO Auto-generated method stub
		return null;
	}

}
